package com.laikan.reader.core.utils;

import com.laikan.library.utils.SPUtil;
import com.laikan.reader.core.LaikanApplication;
import com.laikan.reader.core.events.LaiKanEvent;

import java.util.ArrayList;

public class SystemUtil {

    /**
     * 是否登录， true 登录， false 为未登录
     */
    public static boolean isLogin() {
        return !(null == SPUtil.getString("user_id", "") || "0".equals(SPUtil.getString("user_id", "")) || "".equals(SPUtil.getString("user_id", "")));
    }

    /**
     * 检查是否还有红点显示
     */
    public static void checkRedDotShow(){
        ArrayList<Boolean> booleens = new ArrayList<>();
        boolean share_red_point = SPUtil.getBoolean("share_red_point", true);
        boolean checkversion_update = SPUtil.getBoolean("checkversion_update", false);
        boolean feedback_red_point = SPUtil.getBoolean("feedback_red_point", false);
        booleens.add(share_red_point);
        booleens.add(checkversion_update);
        booleens.add(feedback_red_point);

        LaiKanEvent laiKanEvent = LaiKanEvent.getInstance();
        if(booleens.contains(true)){
            laiKanEvent.setEventID(LaiKanEvent.EVENT_ID_RET_DOT_VISIBLE);
        }else {
            laiKanEvent.setEventID(LaiKanEvent.EVENT_ID_RET_DOT_GONE);
        }
        LaikanApplication.postEvent(laiKanEvent);
    }
}
